//
// Created by wuzhe on 2022/3/31.
//

#ifndef UNIVERSEROOM_UNIVERSEDATAGRAM_HH
#define UNIVERSEROOM_UNIVERSEDATAGRAM_HH


#include <cstdlib>
#include <cstring>
#include "Console.h"

// ----------------------
// | U  | N  | I  | V  |
// | T  | -  | LENGTH  |
// |       ROOMID      |
// |       content     |
// ----------------------
// head of datagram
const char magic[4] = {'U','N','I','V'};
#pragma pack(push, 1)
typedef struct UniverseDatagramHead {
    char magic[4];
    char type;
    char isSlave;
    unsigned short length;
    int roomId;
} UnivHead;
#pragma pack(pop)
class ParseRes {
public:
    UnivHead* head;
    char *content;
    int len;
    void free() const {
        ::free(head);
        ::free(content);
    }
};


#endif //UNIVERSEROOM_UNIVERSEDATAGRAM_HH
